/*
 * @Author: Wxx
 * @Date: 2022-02-28 14:15:19
 * @LastEditors: Wxx
 * @LastEditTime: 2022-02-28 14:20:11
 * @Description:
 */
import React, { Component } from "react";
interface IState {
  text: string;
  list: string[];
}
export default class todolist extends Component<any, IState> {
  state = {
    text: "",
    list: [],
  };
  myRef = React.createRef<HTMLInputElement>();
  render() {
    const { list } = this.state;
    return (
      <div>
        <input ref={this.myRef} />
        <button
          onClick={() => {
            console.log((this.myRef.current as HTMLInputElement).value);
            this.setState({
              list: [...list, (this.myRef.current as HTMLInputElement).value],
            });
          }}
        >
          click
        </button>
        {list.map((item) => (
          <li key={item}>{item}</li>
        ))}
      </div>
    );
  }
}
